package game.helper;

import game.entity.AbsSprite;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class ArmyBoundary {
	static Vector2 A = new Vector2(20, 00);
	static Vector2 B = new Vector2(170, 150);

	public static void setA(Vector2 a) {
		A = a;
	}

	public static void setB(Vector2 b) {
		B = b;
	}
	
	public static Vector2 getA() {
		return A;
	}

	public static Vector2 getB() {
		return B;
	}
	
	public static float getX(float y) {
		return B.x - ((B.x-A.x)*(B.y-y))/(B.y-A.y);
	}
	
	public static boolean isInsection(AbsSprite sprite)
	{
		float x = getX(sprite.getY());
		if((sprite.getX() <= x) &&(x <= sprite.getX()+sprite.getWidth()))
			return true;
		return false;
	}
	

	public static boolean isInsection(Rectangle rect)
	{
		float x = getX(rect.getY());
		if((rect.getX() <= x) &&(x <= rect.getX()+rect.getWidth()))
			return true;
		return false;
	}
	
	
}
